#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 110;
char a[maxn][65];
map<unsigned long long,int>mp;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,m;
		scanf("%d %d",&n,&m);
		unsigned long long ans = pow(2,m)-1;
		unsigned long long mid = (0+ans)/2;
		
		for(int i = 0;i<n;i++)
		{
			unsigned long long num = 0;
			for(int j = 0;j<m;j++)
			{
				cin>>a[i][j];
				num = num*2+(a[i][j]-'0')
			}
			mp[num]++;
			if(num<mid&&(ans%2==0))
			{
				ans--;
				for(unsigned long long i = mid+1;;i++)
				{
					if(mp[mid+1]!=1)
					{
						mid = i;
						break;
					}	
				}
			}
			else if
		}
	}
}
